package com.example.zxw.ui.items

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Divider
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.zxw.entity.NewsListEntity

@Composable
fun NewsItemText(entity: NewsListEntity) {
    Column(modifier = Modifier.padding(horizontal = 20.dp, vertical = 10.dp)) {
        Text(text = entity.title, style = TextStyle(fontSize = 18.sp))
        Row {
            Text(text = entity.source, style = TextStyle(fontSize = 11.sp, color = Color.Gray))
            Text(
                text = entity.pubtime,
                style = TextStyle(fontSize = 11.sp, color = Color.Gray),
                modifier = Modifier.padding(start = 8.dp)
            )
        }
        Divider(color = Color.Gray, thickness = 0.5.dp)
    }
}

@Preview
@Composable
fun previewNewsItemText(){
    NewsItemText(entity = NewsListEntity().apply {
        source = "source"
        pubtime = "2022"
        title = "我是一个标题"
    })
}